package cn.dgut.FrontManger;

import cn.dgut.Utils.JDBCUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/CheckCourse")
public class CheckCourseServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int exsit = 0;
        String sid = request.getParameter("sid");
        String cid = request.getParameter("cid");
        String sql = "select * from Select_Course where course_id="+cid+" and sid="+sid;
        int count = new JDBCUtils().count(sql, 0);
        if(count!=0){
            exsit = 1;
        }
        response.setContentType("application/json,charset=utf-8");
        String strJson = "{\"exsit\":\""+exsit+"\"}";
        response.getWriter().println(strJson);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}